//2009/08/30 00:39:08
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <algorithm>

using namespace std;

class KnockoutTourney
{
public:
    int meetRival(int N, int you, int rival)
    {
		N = (int)log2(N);
		int i = 1;
		while(i <= N)
		{
			if(abs(you - rival) == 1 && min(you, rival) % 2 == 1)
				return i;
			you = (you + 1) / 2;
			rival = (rival + 1) / 2;
			i++;
		}
    }
};
